package com.chainyoung.component_tmperson.ui.activity;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chainyoung.common.base.BaseActivity;
import com.chainyoung.common.bus.AppManagerEvent;
import com.chainyoung.common.bus.RxBus;
import com.chainyoung.common.constant.LibConstant;
import com.chainyoung.common.di.AppComponent;
import com.chainyoung.common.event.BaseEvent;
import com.chainyoung.common.utils.SPUtil;
import com.chainyoung.common.utils.StringUtil;
import com.chainyoung.common.utils.ToastUtil;
import com.chainyoung.component_tmperson.R;
import com.chainyoung.component_tmperson.R2;
import com.chainyoung.component_tmperson.di.component.DaggerPersonActivityComponent;
import com.chainyoung.component_tmperson.di.module.PersonActivityModule;
import com.chainyoung.component_tmperson.ui.mvp.contract.FeedBackContract;
import com.chainyoung.component_tmperson.ui.mvp.presenter.FeedBackPresenter;
import com.chainyoung.router.RouterConstants;
import com.chainyoung.router.RouterUtils;

import org.simple.eventbus.EventBus;

import java.util.TreeMap;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static com.chainyoung.common.bus.AppManagerEvent.APP_EXIT;
import static com.chainyoung.common.bus.AppManagerEvent.KILL_ALL;

public class SettingActivity extends BaseActivity<FeedBackPresenter> implements FeedBackContract.View {


    @BindView(R2.id.et_content)
    EditText etContent;

    @Override
    protected void setupActivityComponent(AppComponent appComponent) {
        DaggerPersonActivityComponent.builder()
                .appComponent(appComponent)
                .personActivityModule(new PersonActivityModule(this))
                .build()
                .inject(this);
    }

    @Override
    protected void initUI() {
        setCurrentTitle(R.string.tmperson_feedback);
        //showAndSetBarRightText(R.string.tmperson_login_out);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.tmperson_activity_setting;
    }

    @OnClick(R2.id.tv_submit)
    void submit() {
        if (StringUtil.viewGetTextIsEmpty(etContent)) {
            ToastUtil.showToast(etContent.getHint().toString());
            return;
        }
        TreeMap<String, Object> map = new TreeMap<>();
        map.put("token", SPUtil.getString(LibConstant.TOKEN));
        map.put("content", StringUtil.viewGetText(etContent));
        mPresenter.feedBack(map);
    }

    @Override
    public void onRightTxtClicked(View v) {
        super.onRightTxtClicked(v);


    }


    @Override
    public void onFeedBackSuccess(String data) {
        ToastUtil.showToast(getString(R.string.tmperson_feed_back_success));
        etContent.setText("");
    }


}
